// Package weed
// wrapping github.com/ginuerzh/weedo
// https://github.com/ginuerzh/weedo

package weed

import (
	"errors"
	"github.com/astaxie/beego"
	"github.com/ginuerzh/weedo"
	"io"
)

var (
	client *weedo.Client
)

func init() {
	master := beego.AppConfig.String("weed_master")
	filter := beego.AppConfig.String("weed_filter")
	client = weedo.NewClient(master, filter)
}

func Upload(filename, mimeType string, file io.Reader) (fid string, size int64, err error) {
	if client != nil {
		return client.AssignUpload(filename, mimeType, file)
	}
	return "", 0 , errors.New("weed client null")
}

func Delete(fid string, count int) (err error) {
	if client != nil {
		return client.Delete(fid, count)
	}
	return errors.New("weed client null")
}